﻿/*	
	stencil - action script 3 isometric game engine.

	http://code.google.com/p/stencilas3/
	
	Copyright (c) 2010 Max Zhuravkov, All Rights Reserved.

	Permission is hereby granted, free of charge, to any person obtaining a copy of
	this software and associated documentation files (the "Software"), to deal in
	the Software without restriction, including without limitation the rights to
	use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
	of the Software, and to permit persons to whom the Software is furnished to do
	so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in all
	copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
	SOFTWARE.
*/
package stencil.core.engine 
{
	import flash.events.IEventDispatcher;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import stencil.core.engine.camera.CameraModeSettings;
	import stencil.core.engine.camera.ICameraMode;
	
	[Event(name="stnVisibleAreaChange", type="stencil.core.engine.events.CameraModelEvent")] 
	
	[Event(name="stnViewportChange", type="stencil.core.engine.events.CameraModelEvent")] 
	
	
	/**
	 * Defines methods and properties for controlling camera behaviour.
	 * 
	 * @author Max Zhuravkov
	 */
	public interface ICameraModel extends IEventDispatcher {
		
		
		/**
		 * Viewport dimensions.
		 */
		function set viewPort(value:Rectangle):void;
		
		function get viewPort():Rectangle;
		
		/**
		 * An extra space.
		 */
		function set extraSpace(value:Rectangle):void;
		
		function get extraSpace():Rectangle;
		
		/**
		 * The grid object used by this camera.
		 */
		function get grid():IGrid;
		
		
		/**
		 * Returns currently visible area in global coordinates. 
		 */
		function get visibleArea():Rectangle;
		
		/**
		 * Sets active mode of this camera to the particular mode that was previously registered with the specified name value.
		 * if there is no such mode has been registered ArgumentError is thrown.
		 */
		function set activeMode(value:String):void;
		
		function get activeMode():String;
		
		/**
		 * Registers the given ICameraMode instance within this camera using the specified name.
		 * 
		 * @param	name	the	name of this mode.
		 * @param	mode	an instance of ICameraMode.
		 * @param	modeSettings	the settings to be used.
		 * @param	setAsActive		whether to set the given mode as active or not.
		 */
		function addMode(name:String, mode:ICameraMode, modeSettings:CameraModeSettings, setAsActive:Boolean = false):void;
		
		/**
		 * Updates settings of the specified mode.
		 * 
		 * @param	name	the name of camera mode which settings should be changed. (If there is no such mode ArgumentError is thrown)
		 * @param	settings	the settings.
		 */
		function changeModeSettings(name:String, settings:CameraModeSettings):void;
		
		/**
		 * Removes the specified mode. If the mode with the given name do not exist ArgumentError is thrown. 
		 * 
		 * @param	name	the name of mode to be removed.
		 */
		function removeMode(name:String):void;
		
		/**
		 * Adds display.
		 * 
		 * @param	display
		 */
		function addDisplay(display:ICameraDisplay):void;
		
		/**
		 * Removes display.
		 * 
		 * @param	display
		 */
		function removeDisplay(display:ICameraDisplay):void;
		
		/**
		 * Returns true if the given display ls attached to this camera object.
		 * 
		 * @param	display
		 * @return
		 */
		function hasDisplay(display:ICameraDisplay):Boolean;
		
		/**
		 * Updates position of a camera according to recent changes.
		 * 
		 * @return	whether or not visible area was changed.
		 */
		function update(dt:Number):Boolean;
		
		/**
		 * Updates positions of attached displays.
		 */
		function updatePosition(areaChanged:Boolean):void;
	}
	
}